package com.sgb.member.ui.adapter;

import android.app.Activity;

import com.sgb.member.BR;
import com.sgb.member.databinding.ItemOtherLeasePersonBinding;
import com.sgb.member.entity.MemberLeaseBean;
import com.sgb.member.weight.MemberCallback;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class MemberPersonAdapter<T> extends BaseRecycleAdapter<T> {

    MemberCallback memberCallback;

    public MemberPersonAdapter(Activity activity, int layoutId, List<T> datas) {
        super(activity, layoutId, datas);
    }

    public MemberPersonAdapter(Activity activity, int layoutId, List<T> datas, MemberCallback memberCallback) {
        super(activity, layoutId, datas);
        this.memberCallback = memberCallback;
    }

    @Override
    public void convert(ItemViewHolder holder, final T t) {
        if (t instanceof MemberLeaseBean) {
            // 会员租赁
            MemberLeaseBean entity = (MemberLeaseBean) t;
            ItemOtherLeasePersonBinding binding = (ItemOtherLeasePersonBinding) holder.getmBinding();
            if (binding == null) return;
            binding.setVariable(BR.viewModel, entity);
            binding.tvDistance.setText(entity.getProvinceName()+entity.getCityName()+entity.getAreaName());

            if (Double.parseDouble(entity.getRentalPrice()) > 0) {
                binding.tvLeasePrice.setText(entity.getRentalPrice() + entity.getPriceUnitName());
            } else {
                binding.tvLeasePrice.setText("面议");
            }
            binding.executePendingBindings();
        }
    }


    private IChildClick<T> iChildClick;

    public void onIChildClick(IChildClick<T> iChildClick) {
        this.iChildClick = iChildClick;
    }

    public interface IChildClick<T> {
        void onClick(T tenderListEntity);
    }


}
